<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNo">
              <a-input v-model="model.subjectNo" placeholder="请输入科目代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectName">
              <a-input v-model="model.subjectName" placeholder="请输入科目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdm">
              <a-input v-model="model.khdm" placeholder="请输入客户代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjgh">
              <a-input v-model="model.nbjgh" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdqdm">
              <a-input v-model="model.jrjgdqdm" placeholder="请输入金融机构地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人国民经济部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrgmjjbm">
              <a-input v-model="model.jkrgmjjbm" placeholder="请输入借款人国民经济部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrzjlx">
              <a-input v-model="model.jkrzjlx" placeholder="请输入借款人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrzjdm">
              <a-input v-model="model.jkrzjdm" placeholder="请输入借款人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrhy">
              <a-input v-model="model.jkrhy" placeholder="请输入借款人行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrdqdm">
              <a-input v-model="model.jkrdqdm" placeholder="请输入借款人地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人经济成分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrjjcf">
              <a-input v-model="model.jkrjjcf" placeholder="请输入借款人经济成分"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="借款人企业规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jkrqygm">
              <a-input v-model="model.jkrqygm" placeholder="请输入借款人企业规模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款借据编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkjjbm">
              <a-input v-model="model.wtdkjjbm" placeholder="请输入委托贷款借据编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款合同编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkhtbm">
              <a-input v-model="model.wtdkhtbm" placeholder="请输入委托贷款合同编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款实际投向" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dksjtx">
              <a-input v-model="model.dksjtx" placeholder="请输入贷款实际投向"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款发放日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkffrq">
              <j-date placeholder="请选择委托贷款发放日期" v-model="model.wtdkffrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款到期日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkdqrq">
              <j-date placeholder="请选择委托贷款到期日期" v-model="model.wtdkdqrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="交易流水号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jylsh">
              <a-input v-model="model.jylsh" placeholder="请输入交易流水号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input v-model="model.bz" placeholder="请输入币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款发生金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkfsje">
              <a-input-number v-model="model.wtdkfsje" placeholder="请输入委托贷款发生金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托贷款发生金额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtdkfsjezrmb">
              <a-input-number v-model="model.wtdkfsjezrmb" placeholder="请输入委托贷款发生金额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="利率是否固定" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="llsfgd">
              <a-input v-model="model.llsfgd" placeholder="请输入利率是否固定"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="利率水平" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="llsp">
              <a-input-number v-model="model.llsp" placeholder="请输入利率水平" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="手续费金额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sxfjezrmb">
              <a-input-number v-model="model.sxfjezrmb" placeholder="请输入手续费金额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款担保方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkdbfs">
              <a-input v-model="model.dkdbfs" placeholder="请输入贷款担保方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人国民经济部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrgmjjbm">
              <a-input v-model="model.wtrgmjjbm" placeholder="请输入委托人国民经济部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrzjlx">
              <a-input v-model="model.wtrzjlx" placeholder="请输入委托人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrzjdm">
              <a-input v-model="model.wtrzjdm" placeholder="请输入委托人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrhy">
              <a-input v-model="model.wtrhy" placeholder="请输入委托人行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrdqdm">
              <a-input v-model="model.wtrdqdm" placeholder="请输入委托人地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人经济成分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrjjcf">
              <a-input v-model="model.wtrjjcf" placeholder="请输入委托人经济成分"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="委托人企业规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wtrqygm">
              <a-input v-model="model.wtrqygm" placeholder="请输入委托人企业规模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="发放/收回标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ffhsbs">
              <a-input v-model="model.ffhsbs" placeholder="请输入发放/收回标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款用途" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkyt">
              <a-input v-model="model.dkyt" placeholder="请输入贷款用途"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPAmtDelegateInfForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jsPAmtDelegateInf/jsPAmtDelegateInf/add",
          edit: "/jsPAmtDelegateInf/jsPAmtDelegateInf/edit",
          queryById: "/jsPAmtDelegateInf/jsPAmtDelegateInf/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
